<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script type='text/javascript' src='js/vue.js'></script>
</head>
<body>
    <div id='app'>
        {{msg}}
        <hr>

        <input type="text" v-model.number='a4'>==============
        <input type="text" v-model.number='a1'>+
        <input type="text" v-model.number='a2'>=
        <input :value='a3' type="text" readonly placeholder="结果">

    </div>
    <script type='text/javascript'>
        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'Hello Vue',
                a1:'1',
                a2:'1',
                a3:'33333',
                a4:'4'
            },
            watch:{
                a1(newVal,oldVal){
                    console.log(newVal,oldVal);
                    
                    this.a3=Number(this.a1)+Number(this.a2)
                },
                a2(){
                    this.a3=Number(this.a1)+Number(this.a2)
                }
            }
        });
    </script>
</body>
</html>